/*
 * sm_test.c
 *
 *  Created on: Jul 20, 2012
 *      Author: Eugene Parkhomenko
 */

#include "../sm_error.h"
#include "../sm_debug.h"
#include "../state_machine_pub.h"

typedef enum EN_SM_TEST_STATES_ID_TAG
{
	enSTATE_INITIAL,
	enSTATE_FIRST,
	enSTATE_SECOND,
	enSTATE_FINAL,
} EN_SM_TEST_STATES_ID;

typedef enum EN_SM_TEST_EVENTS_ID_TAG
{
    enEVENT_START,
    enEVENT_MOVE,
    enEVENT_STOP,
} EN_SM_TEST_EVENTS_ID;

void INITIAL_entry(void *pvData)
{
    SM_INFONL(TRUE, "");
}

void INITIAL_exit(void *pvData)
{
    SM_INFONL(TRUE, "");
}

void FIRST_entry(void *pvData)
{
    SM_INFONL(TRUE, "");
}

void FIRST_exit(void *pvData)
{
    SM_INFONL(TRUE, "");
}
void SECOND_entry(void *pvData)
{
    SM_INFONL(TRUE, "");
}

void SECOND_exit(void *pvData)
{
    SM_INFONL(TRUE, "");
}
void FINAL_entry(void *pvData)
{
    SM_INFONL(TRUE, "");
}

void FINAL_exit(void *pvData)
{
    SM_INFONL(TRUE, "");
}

BOOL trans1_guard(void *pvData)
{
    SM_INFONL(TRUE, "");
    return TRUE;
}

void trans1_action(void *pvData)
{
    SM_INFONL(TRUE, "");
}

BOOL trans2_guard(void *pvData)
{
    SM_INFONL(TRUE, "");
    return TRUE;
}

void trans2_action(void *pvData)
{
    SM_INFONL(TRUE, "");
}

BOOL trans3_guard(void *pvData)
{
    SM_INFONL(TRUE, "");
    return TRUE;
}

void trans3_action(void *pvData)
{
    SM_INFONL(TRUE, "");
}

static ST_SM_STATE pstTestStates[] =
{
		{ enSTATE_INITIAL, INITIAL_entry, INITIAL_exit },
		{ enSTATE_FIRST,   FIRST_entry, FIRST_exit },
		{ enSTATE_SECOND,  SECOND_entry, SECOND_exit },
		{ enSTATE_FINAL,   FINAL_entry, FINAL_exit },
};

static ST_SM_TRANSITION pstTestTransitions[] =
{
        { enEVENT_START, enSTATE_INITIAL, enSTATE_FIRST, trans1_guard, trans1_action },
        { enEVENT_MOVE, enSTATE_FIRST, enSTATE_SECOND, trans2_guard, trans2_action },
        { enEVENT_STOP, enSTATE_SECOND, enSTATE_FINAL, trans3_guard, trans3_action },
};

BOOL test_sm_init_null_null_null(void)
{
	return (enSM_ERR_CODE_OK != SM_init(NULL, NULL, NULL)) ? TRUE : FALSE;
}

BOOL test_sm_init_ok_stop_ok(void)
{
    SM_INSTANCE_DESCRIPTOR tDescr = { 0 };
    if (enSM_ERR_CODE_OK != SM_init(&tDescr, pstTestStates, pstTestTransitions))
    {
        return FALSE;
    }
    SM_stop(tDescr);
    return TRUE;
}
